package com.ruoyi.web.controller.system;

import com.ruoyi.common.core.page.PageUtil;
import com.ruoyi.common.core.page.ResultEntity;
import com.ruoyi.system.domain.TProdRecord;
import com.ruoyi.system.domain.dto.TProdRecordDTO;
import com.ruoyi.system.domain.vo.TProdRecordVO;
import com.ruoyi.system.service.ITProdRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author wux
 * @date 2023/5/30 10:15
 */
@Api(tags = "(客户端) 生产记录")
@RestController
@RequestMapping("/client/prod/record")
public class TProdRecordController {
    @Autowired
    private ITProdRecordService prodRecordService;

    @PostMapping("/add")
    @ApiOperation(value = "新增生产记录", response = TProdRecord.class)
    public ResultEntity add(@Valid @RequestBody TProdRecord params) {
        prodRecordService.add(params);
        return ResultEntity.createSuccess();
    }

    @GetMapping("/list")
    @ApiOperation(value = "生产记录查询",response = TProdRecordVO.class)
    public ResultEntity listByPage(TProdRecordDTO params){
        PageUtil.startPage(params);
        return ResultEntity.createSuccess(PageUtil.getPageList(prodRecordService.listByPage(params)));
    }

    @GetMapping("/getByBatchCode")
    @ApiOperation(value = "生产批次记录查询-未检验记录",response = TProdRecordVO.class)
    public ResultEntity getByBatchCode(TProdRecordDTO params){
        params.setProjectId(1L);
        PageUtil.startPage(params);
        params.setCheckFlag(true);
        return ResultEntity.createSuccess(PageUtil.getPageList(prodRecordService.getByBatchCode(params)));
    }

    @GetMapping("/getByBatchCode2")
    @ApiOperation(value = "生产批次记录查询",response = TProdRecordVO.class)
    public ResultEntity getByBatchCode2(TProdRecordDTO params){
        params.setProjectId(1L);
        PageUtil.startPage(params);
        params.setCheckFlag(true);
        return ResultEntity.createSuccess(PageUtil.getPageList(prodRecordService.getByBatchCode2(params)));
    }

}
